def merge_nums(list_target):
    """
        合并相邻不为0的数
    :param list_target:
    :return:
    """
    march_add_num_list = []
    waiting_list = []
    for item in list_target:
        if item != 0:
            if len(waiting_list) == 1 and item != waiting_list[0]:
                march_add_num_list.append(waiting_list[0])
                waiting_list[0] = item
            else:
                waiting_list.append(item)
                if len(waiting_list) == 2:
                    if waiting_list[0] + waiting_list[1] != 0:
                        march_add_num_list.append(waiting_list[0] + waiting_list[1])
                    waiting_list.clear()
    if len(waiting_list) != 0:
        march_add_num_list += waiting_list
    add_num = len(list_target) - len(march_add_num_list)
    march_add_num_list += [0] * add_num
    return march_add_num_list


print(merge_nums([2, 2, 0, 0]))
print(merge_nums([2, 0, 2, 0, 1]))
print(merge_nums([2, 0, 0, 2]))
print(merge_nums([4, 2, 4, 0]))
